home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / alien-glow-button.scm < prev    next >
Encoding:
Text File  |  2009-08-19  |  5.6 KB  |  168 lines

  1. ; GIMP - The GNU Image Manipulation Program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Alien Glow themed button
  5. ; Copyright (c) 1997 Adrian Likins
  6. ; aklikins@eos.ncsu.edu
  7. ;
  8. ; based on code from Frederico Mena Quintero (Quartic)
  9. ; federico@nuclecu.unam.mx
  10. ;
  11. ; This program is free software: you can redistribute it and/or modify
  12. ; it under the terms of the GNU General Public License as published by
  13. ; the Free Software Foundation; either version 3 of the License, or
  14. ; (at your option) any later version.
  15. ;
  16. ; This program is distributed in the hope that it will be useful,
  17. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. ; GNU General Public License for more details.
  20. ;
  21. ; You should have received a copy of the GNU General Public License
  22. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  23.  
  24.  
  25. (define (script-fu-alien-glow-button text
  26.                                      font
  27.                                      size
  28.                                      text-color
  29.                                      glow-color
  30.                                      bg-color
  31.                                      padding
  32.                                      glow-radius
  33.                                      flatten)
  34.  
  35.   (define (text-width extents)
  36.     (car extents))
  37.  
  38.   (define (text-height extents)
  39.     (cadr extents))
  40.  
  41.   (define (text-ascent extents)
  42.     (caddr extents))
  43.  
  44.   (define (text-descent extents)
  45.     (cadr (cddr extents)))
  46.  
  47.   (define (blend-bumpmap img
  48.                          drawable
  49.                          x1
  50.                          y1
  51.                          x2
  52.                          y2)
  53.     (gimp-edit-blend drawable FG-BG-RGB-MODE DARKEN-ONLY-MODE
  54.                      GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE
  55.                      FALSE 0 0 TRUE
  56.                      x1 y1 x2 y2)
  57.   )
  58.  
  59.   (let* (
  60.         (text-extents (gimp-text-get-extents-fontname text
  61.                                                       size
  62.                                                       PIXELS
  63.                                                       font))
  64.         (ascent (text-ascent text-extents))
  65.         (descent (text-descent text-extents))
  66.  
  67.         (img-width (+ (* 2  padding)
  68.                       (text-width text-extents)))
  69.         (img-height (+ (* 2 padding)
  70.                        (+ ascent descent)))
  71.         (layer-height img-height)
  72.         (layer-width img-width)
  73.         (img-width (+ img-width glow-radius))
  74.         (img-height (+ img-height glow-radius))
  75.         (img (car (gimp-image-new img-width img-height RGB)))
  76.         (bg-layer (car (gimp-layer-new img
  77.                                        img-width img-height RGBA-IMAGE
  78.                                        "Background" 100 NORMAL-MODE)))
  79.         (glow-layer (car (gimp-layer-new img
  80.                                          img-width img-height RGBA-IMAGE
  81.                                          "Glow" 100 NORMAL-MODE)))
  82.         (button-layer (car (gimp-layer-new img
  83.                                            layer-width layer-height RGBA-IMAGE
  84.                                            "Button" 100 NORMAL-MODE)))
  85.         )
  86.  
  87.     (gimp-context-push)
  88.  
  89.     (gimp-image-undo-disable img)
  90.  
  91.     ; Create bumpmap layer
  92.  
  93.     (gimp-image-add-layer img bg-layer -1)
  94.     (gimp-context-set-foreground '(0 0 0))
  95.     (gimp-context-set-background bg-color)
  96.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  97.     (gimp-image-add-layer img glow-layer -1)
  98.  
  99.     ; Create text layer
  100.  
  101.     (gimp-image-add-layer img button-layer -1)
  102.     (gimp-layer-set-offsets button-layer (/ glow-radius 2) (/ glow-radius 2))
  103.     (gimp-selection-none img)
  104.     (gimp-rect-select img 0 0 img-width img-height CHANNEL-OP-REPLACE FALSE 0)
  105.     (gimp-context-set-foreground '(100 100 100))
  106.     (gimp-context-set-background '(0 0 0))
  107.  
  108.     (gimp-edit-blend button-layer FG-BG-RGB-MODE NORMAL-MODE
  109.                      GRADIENT-SHAPEBURST-ANGULAR 100 0 REPEAT-NONE FALSE
  110.                      FALSE 0 0 TRUE
  111.                      0 0 img-height img-width)
  112.  
  113.     (gimp-edit-clear glow-layer)
  114.  
  115.     (gimp-rect-select img
  116.                       (/ glow-radius 4)
  117.                       (/ glow-radius 4)
  118.                       (- img-width (/ glow-radius 2))
  119.                       (- img-height (/ glow-radius 2))
  120.                       CHANNEL-OP-REPLACE FALSE 0 )
  121.  
  122.     (gimp-context-set-foreground glow-color)
  123.     (gimp-edit-fill glow-layer FOREGROUND-FILL)
  124.     (gimp-selection-none img)
  125.     (plug-in-gauss-rle RUN-NONINTERACTIVE img glow-layer glow-radius TRUE TRUE)
  126.     (gimp-context-set-foreground text-color)
  127.     (let (
  128.          (textl (car (gimp-text-fontname
  129.                       img -1 0 0 text 0 TRUE size PIXELS font)))
  130.          )
  131.       (gimp-layer-set-offsets textl
  132.                               (+  padding (/ glow-radius 2))
  133.                               (+ (+ padding descent) (/ glow-radius 2)))
  134.     )
  135.     ; Done
  136.     (gimp-selection-none img)
  137.     (gimp-image-undo-enable img)
  138.     (if (= flatten TRUE)
  139.         (gimp-image-flatten img)
  140.     )
  141.  
  142.     (gimp-display-new img)
  143.  
  144.     (gimp-context-pop)
  145.   )
  146. )
  147.  
  148. (script-fu-register "script-fu-alien-glow-button"
  149.   _"B_utton..."
  150.   _"Create a button graphic with an eerie glow for web pages"
  151.   "Adrian Likins"
  152.   "Adrian Likins"
  153.   "July 1997"
  154.   ""
  155.   SF-STRING     _"Text"               "Hello world!"
  156.   SF-FONT       _"Font"               "Sans Bold"
  157.   SF-ADJUSTMENT _"Font size (pixels)" '(22 2 100 1 1 0 1)
  158.   SF-COLOR      _"Text color"         "black"
  159.   SF-COLOR      _"Glow color"         '(63 252 0)
  160.   SF-COLOR      _"Background color"   "black"
  161.   SF-ADJUSTMENT _"Padding"            '(6 1 100 1 10 0 1)
  162.   SF-ADJUSTMENT _"Glow radius"        '(10 1 200 1 10 0 1)
  163.   SF-TOGGLE     _"Flatten image"      TRUE
  164. )
  165.  
  166. (script-fu-menu-register "script-fu-alien-glow-button"
  167.                          "<Image>/File/Create/Web Page Themes/Alien Glow")
  168.